import os

import markdown
from django.shortcuts import render
from django.views.generic.base import TemplateView
from django.core.urlresolvers import Resolver404

from website.models import Article
from blog.settings import BASE_DIR


class ArticleListView(TemplateView):

    template_name = 'index.html'


class ArticleDetailView(TemplateView):
    template_name = 'article.html'

    def get_context_data(self, **kwargs):
        context = super(ArticleDetailView, self).get_context_data()
        obj = Article.objects.get(id=kwargs['id'])
        context = {}
        m = markdown.markdown(obj.content.read().decode('utf8'))
        context['content'] = m
        return context

    